<?php
package("Utils");
package("Query");

/**
 * Factory which generates query builders
 *
 */
class Query_Factory {
	
	/**
	 * Prevent this class from being constructed normally
	 *
	 */
	private function __construct() {
		
	}
	
	/**
	 * Construct a new query builder
	 *
	 * @param String $classname
	 * @param array $args
	 * @return Query_Builder
	 */
	public function construct($classname, array $args) {
		try {
			return Utils_Reflection_Facade::getInstance($classname, $args);
		} catch (Utils_Reflection_Exception $e) {
			throw new Query_Exception($e);
		}
	}
	
	/**
	 * Retrieve a single instance of the factory
	 *
	 * @return Query_Factory
	 */
	public static function getSingleton() {
		static $singleton;
		if (!isset($singleton)) {
			$singleton = new Query_Factory();
		}
		return $singleton;
	}
}
?>